//
//  ViewController.m
//  MJAVFoundationDemo
//
//  Created by apple on 16/9/7.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ViewController.h"
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *mainTableView;//创建一个表
@property(nonatomic,strong)NSArray *dataSource;//创建表的数据源
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    self.title=@"demo";
    [self.view addSubview:self.mainTableView];
    self.automaticallyAdjustsScrollViewInsets=NO;//这一行代码用于表格跟电池栏距离调整，不设置的话会自动在表上加上64个距离
    _dataSource=@[@"录音",@"相册、拍照",@"音乐播放",@"视频播放",@"二维码扫描",@"粒子发散",@"发射动画",@"粒子掉落",@"视频聊天",@"语音聊天",@"锁屏"];
}

//懒加载的方式初始化表，只有self.打点调用时才会执行到这里
-(UITableView *)mainTableView
{
    if (!_mainTableView)
    {
        _mainTableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 64, KWIDTH, KHEIGHT-64)];
        //设置表代理才能用它的代理方法
        _mainTableView.delegate=self;
        _mainTableView.dataSource=self;
        _mainTableView.rowHeight=44;
        _mainTableView.tableFooterView=[UIView new];
        //注册单元格
        [_mainTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"reuseCell"];
        
    }
    return _mainTableView;
}
//表代理方法
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataSource.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"reuseCell" forIndexPath:indexPath];
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    cell.textLabel.text=_dataSource[indexPath.row];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0:
        {
            SoundRecordingViewController *soundView=[[SoundRecordingViewController alloc]init];
            [self.navigationController pushViewController:soundView animated:YES];
        }
            break;
        case 1:
        {
            TakePhotoViewController *photoView=[[TakePhotoViewController alloc]init];
            [self.navigationController pushViewController:photoView animated:YES];
        }
            
            break;
        case 2:
        {
            MusicPlayerViewController *musicView=[[MusicPlayerViewController alloc]init];
            [self.navigationController pushViewController:musicView animated:YES];
        }
            
            break;
        case 3:
        {
            MediaPlayerViewController *mediaPlayerView=[[MediaPlayerViewController alloc]init];
            [self.navigationController pushViewController:mediaPlayerView animated:YES];
        }
            
            break;
        case 4:
        {
            CodeScanViewController *codeScan=[[CodeScanViewController alloc]init];
            [self.navigationController pushViewController:codeScan animated:YES];
        }
            
            break;
        case 5:
        {

            [self.navigationController pushViewController:[[DazViewController alloc] init] animated:YES];
        }
            
            break;
        case 6:
        {
            
            [self.navigationController pushViewController:[[SprayViewController alloc] init] animated:YES];
        }
            
            break;
        case 7:
        {
            
            [self.navigationController pushViewController:[[DropViewController alloc] init] animated:YES];
        }
            
            break;
        case 10:
        {
            [self.navigationController pushViewController:[[LockScreenViewController alloc]init] animated:YES];
        }
            break;
        default:
            break;
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
